package com.elder.web.controller.business;

import com.elder.common.utils.DateUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.time.temporal.TemporalAdjusters;

@Slf4j
@Component
public class TimeTask {

    /***
     * @description 表示在每月的1日的凌晨2点调整任务
     * @author zyk
     * @date 2024/2/29 16:00
     */
    @Scheduled(cron = "0 0 2 1 * ? *")
    public void refresh(){
        log.info("//// 定时刷新");
        //删除退住的人员记录
        
      //业务代码
    }
    public static void main(String[] args) {
        LocalDate currentDate = LocalDate.now();
        LocalDate firstDayOfMonth = currentDate.with(TemporalAdjusters.firstDayOfMonth());
        LocalDateTime firstDayOfMonthStartOfDay = firstDayOfMonth.atStartOfDay();

        long timestamp = firstDayOfMonthStartOfDay.toEpochSecond(ZoneOffset.UTC);
        System.out.println("Timestamp: " + DateUtils.getDayStartTime(timestamp));
    }

}
